package lanou.autohome;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

/**
 * Created by dllo on 16/8/25.
 */
public class MyToast {

    public MyToast(Context context , String prompt) {
        Toast toast = new Toast(context);
        toast.setDuration(Toast.LENGTH_SHORT);
        View view = View.inflate(context , R.layout.toast_custom , null);
        TextView textView = (TextView) view.findViewById(R.id.toast_tv);
        textView.setText(prompt);
        //设置根视图
        toast.setView(view);
        //设置对齐方式
        toast.setGravity(Gravity.CENTER , 0 , 0);
        //显示吐司
        toast.show();
    }

}
